package nongchang.kuaijiecaifu.com.ncapp_android.ui;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.widget.adapter.TabsAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.activity.BaseActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.orderfragment.AllFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.orderfragment.EvaluatedFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.orderfragment.PendingpayFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.orderfragment.ReceiptFragment;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.fragment.orderfragment.ShippedFragment;

public class AllOrderActivity extends BaseActivity {
    @BindView(R.id.orderby)
    TabLayout mTabOrderBy;
    @BindView(R.id.pager)
    ViewPager mViewPager;
    @BindView(R.id.rl_select)
    RelativeLayout rlSelect;
    @BindView(R.id.ll_selected)
    LinearLayout llSelect;
    @BindView(R.id.view_background)
    View view_background;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_all_order);
        ButterKnife.bind(this);
//        Fragment fragments[] = {new AllFragment(),new PendingpayFragment(),new ShippedFragment(),new ReceiptFragment(),new EvaluatedFragment()};
        Fragment fragments[] = {new AllFragment()};

        mViewPager.setAdapter(new TabsAdapter(getSupportFragmentManager(), fragments));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("全部"), true);
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("待付款"));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("待发货"));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("待收货"));
        mTabOrderBy.addTab(mTabOrderBy.newTab().setText("待评价"));
        mTabOrderBy.setOnTabSelectedListener(onTabSelectedListener);
        mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabOrderBy));
    }

    TabLayout.OnTabSelectedListener onTabSelectedListener = new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            mViewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    };
    @OnClick({R.id.btn_back,R.id.btn_right,R.id.btn_cancel})
    void onClick(View view){
        switch (view.getId()){
            case R.id.btn_back:
                finish();
                break;
            case R.id.btn_right:
                rlSelect.setVisibility(View.GONE);
                llSelect.setVisibility(View.VISIBLE);
                view_background.setVisibility(View.VISIBLE);
                break;
            case R.id.btn_cancel:
                rlSelect.setVisibility(View.VISIBLE);
                llSelect.setVisibility(View.GONE);
                view_background.setVisibility(View.GONE);
                break;
        }
    }
}
